﻿using Basic.FlowExtendService;
using Basic.FlowLocalEvent.Model;
using Basic.FlowModel;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowLocalEvent.FlowApp
{
    [LocalEventName("Enable","Stop")]
    internal class SetAppPowerIsEnable : IEventHandler<FlowAppEvent>
    {
        private IPowerService _Service;

        public SetAppPowerIsEnable(IPowerService service)
        {
            this._Service = service;
        }

        public void HandleEvent(FlowAppEvent data, string eventName)
        {
            if (data.App.AppType == FlowRemoteModel.FlowAppType.内部应用)
            {
                if (eventName == "Enable")
                {
                    _Service.Enable(ConstDic.FlowAppLinkType, data.App.Id);
                }
                else
                {
                    _Service.Stop(ConstDic.FlowAppLinkType, data.App.Id);
                }
            }
        }
    }
}
